<!DOCTYPE html><html lang="zh-tw"><head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>&#x7B80;&#x4ECB; | ECMAScript 6&#x5165;&#x95E8;</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.4.3">
        <meta name="author" content="&#x5927;&#x9F3B;&#x5B50;">
        
        <meta name="HandheldFriendly" content="true">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://wohugb.gitbooks.io/ecmascript-6/content/gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="https://gstatic.gitbook.com/images/b1c4c86ca817a71628d2debe73be9a64.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="static/css/style.css">
    
        
        <link rel="stylesheet" href="static/css/website.css">
        
    
    

        
    
    
    <link rel="next" href="let.html">
    
    
    <link rel="prev" href="index.html">
    

        
    
<style>
    .book .book-summary .book-search,
    .book .book-summary ul.summary {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
    }
    .book-summary {
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        flex-direction: column;
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        overflow-y: auto;
    }
    .book-summary > nav {
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-y: overlay;
    }
    .gl-wrapper {
        margin: 0;
        display: block;
        padding: 0;
        position: relative;
        line-height: 15px;
        background: #fafafa;
    }
    .gl-wrapper:before {
        background: -webkit-linear-gradient(to bottom, rgba(250,250,250,0) 0%, #fafafa 100%);
        background: -moz-linear-gradient(to bottom, rgba(250,250,250,0) 0%, #fafafa 100%);
        top: -24px;
        width: 100%;
        height: 24px;
        content: "";
        display: block;
        position: absolute;
        background: linear-gradient(to bottom, rgba(250,250,250,0) 0%, #fafafa 100%);
    }
    .book.color-theme-1 .gl-wrapper {
        background: #121212;
    }
    .book.color-theme-1 .gl-wrapper:before {
        background: -webkit-linear-gradient(to bottom, rgba(18,18,18,0) 0%, #121212 100%);
        background: -moz-linear-gradient(to bottom, rgba(18,18,18,0) 0%, #121212 100%);
        background: linear-gradient(to bottom, rgba(18,18,18,0) 0%, #121212 100%);
    }
    .book.color-theme-2 .gl-wrapper {
        background: #2e3243;
    }
    .book.color-theme-2 .gl-wrapper:before {
        background: -webkit-linear-gradient(to bottom, rgba(46,50,67,0) 0%, #2e3243 100%);
        background: -moz-linear-gradient(to bottom, rgba(46,50,67,0) 0%, #2e3243 100%);
        background: linear-gradient(to bottom, rgba(46,50,67,0) 0%, #2e3243 100%);
    }
    .gl-wrapper .gitbook-link {
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        color: #9DAAB6;
        margin: 16px;
        display: flex;
        padding: 0;
        align-items: center;
        margin-left: 32px;
        padding-top: 8px;
        padding-left: 16px;
        border-radius: 3px;
        padding-right: 16px;
        padding-bottom: 8px;
        text-decoration: none;
        background-color: #E6ECF1;
        -webkit-box-align: center;
    }
    .gl-wrapper .tm-logo {
        margin: 0;
        display: block;
        padding: 0;
        font-size: 40px;
    }
    .gl-wrapper .tm-content {
        flex: 1;
        margin: 0;
        display: block;
        padding: 0;
        padding-left: 16px;
    }
    .gl-wrapper .tm-content .container {
        margin: 0;
        display: block;
        padding: 0;
    }
    .gl-wrapper .tm-content .tm-container .tm-text {
        font-size: 12px;
        font-family: "Roboto", sans-serif;
        font-weight: 400;
        line-height: 1.625;
    }
</style></head>
    <body>
        
        
    <div class="book" data-level="1" data-basepath=".." data-revision="Sun Oct 25 2015 02:52:03 GMT+0000 (UTC)">
    

<div class="book-summary">
    <div class="book-search" role="search">
        <input type="text" placeholder="&#x8F38;&#x5165;&#x4E26;&#x641C;&#x5C0B;" class="form-control">
    </div>
    <nav role="navigation">
        <ul class="summary">
            
            
            
                
                <li>
                    <a href="javascript:;" target="blank" class="custom-link">ECMAScript 6&#x5165;&#x95E8;</a>
                </li>
            
            

            
            <li class="divider"></li>
            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="index.html">
                
                        <i class="fa fa-check"></i>
                        
                        &#x524D;&#x8A00;
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1" data-path="docs/intro.html">
            
                
                    <a href="">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        &#x7B80;&#x4ECB;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="docs/let.html">
            
                
                    <a href="let.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        let&#x548C;const&#x547D;&#x4EE4;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="docs/destructuring.html">
            
                
                    <a href="destructuring.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        &#x53D8;&#x91CF;&#x7684;&#x89E3;&#x6784;&#x8D4B;&#x503C;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4" data-path="docs/string.html">
            
                
                    <a href="string.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        &#x5B57;&#x7B26;&#x4E32;&#x7684;&#x6269;&#x5C55;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5" data-path="docs/number.html">
            
                
                    <a href="number.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        &#x6570;&#x503C;&#x7684;&#x6269;&#x5C55;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6" data-path="docs/array.html">
            
                
                    <a href="array.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        &#x6570;&#x7EC4;&#x7684;&#x6269;&#x5C55;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7" data-path="docs/object.html">
            
                
                    <a href="object.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        &#x5BF9;&#x8C61;&#x7684;&#x6269;&#x5C55;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8" data-path="docs/function.html">
            
                
                    <a href="function.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        &#x51FD;&#x6570;&#x7684;&#x6269;&#x5C55;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9" data-path="docs/set-map.html">
            
                
                    <a href="set-map.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        Set&#x548C;Map&#x6570;&#x636E;&#x7ED3;&#x6784;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10" data-path="docs/iterator.html">
            
                
                    <a href="iterator.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        Iterator&#x548C;for...of&#x5FAA;&#x73AF;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="11" data-path="docs/generator.html">
            
                
                    <a href="generator.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.</b>
                        
                        Generator &#x51FD;&#x6570;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12" data-path="docs/promise.html">
            
                
                    <a href="promise.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.</b>
                        
                        Promise&#x5BF9;&#x8C61;
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="13" data-path="docs/class.html">
            
                
                    <a href="class.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>13.</b>
                        
                        Class&#x548C;Module
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="14" data-path="docs/reference.html">
            
                
                    <a href="reference.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>14.</b>
                        
                        &#x53C2;&#x8003;&#x94FE;&#x63A5;
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            
            
        </ul>
    </nav>

<div class="gl-wrapper">
    <a class="gitbook-link" href="javascript:;" target="blank">
        <div class="tm-logo">
            <svg preserveaspectratio="xMidYMid meet" height="1em" width="1em" fill="currentColor" viewbox="0 0 1067 769" xmlns="http://www.w3.org/2000/svg" stroke="none" class="icon-7f6730be--text-3f89f380"><g><path d="M480.026 640.677c17.205 0 31.2 13.997 31.2 31.194s-13.995 31.193-31.2 31.193c-17.197 0-31.193-13.996-31.193-31.193 0-17.197 13.996-31.194 31.193-31.194m489.93-193.226c-17.203 0-31.2-13.998-31.2-31.195 0-17.204 13.997-31.2 31.2-31.2 17.198 0 31.194 13.996 31.194 31.2 0 17.197-13.996 31.195-31.193 31.195m0-127.804c-53.269 0-96.609 43.34-96.609 96.609 0 10.373 1.723 20.702 5.123 30.741L559.328 616.879c-18.132-26.128-47.521-41.617-79.302-41.617-36.821 0-70.391 21.065-86.63 54.003L106.68 478.109c-30.288-15.927-52.965-65.817-50.56-111.223 1.248-23.687 9.438-42.071 21.897-49.17 7.916-4.493 17.436-4.099 27.526 1.188l1.916 1.01c75.96 40.022 324.6 170.981 335.063 175.844 16.157 7.47 25.14 10.5 52.659-2.547l513.958-267.3c7.53-2.844 16.315-10.062 16.315-21.023 0-15.205-15.72-21.199-15.765-21.199-29.218-14.018-74.163-35.054-117.987-55.57C798.033 84.26 691.861 34.547 645.23 10.132c-40.253-21.072-72.655-3.311-78.432.282l-11.227 5.555C345.727 119.743 64.898 258.826 48.911 268.553 20.278 285.973 2.547 320.679.252 363.768c-3.586 68.304 31.261 139.506 81.069 165.634l303.172 156.354c6.83 47.306 47.55 82.725 95.532 82.725 52.78 0 95.808-42.546 96.603-95.14L910.541 492.38c16.93 13.233 37.92 20.486 59.416 20.486 53.268 0 96.61-43.341 96.61-96.61s-43.342-96.61-96.61-96.61" fill-rule="evenodd"></path></g></svg>
        </div>
        <div class="tm-content">
            <div class="tm-container">
                <span class="tm-text">
                    Powered by <b>GitBook</b>
                </span>
            </div>
        </div>
    </a>
</div></div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    <a href="#" class="btn pull-left toggle-summary" aria-label="&#x76EE;&#x9304;"><i class="fa fa-align-justify"></i></a>
    <a href="#" class="btn pull-left toggle-search" aria-label="&#x641C;&#x5C0B;"><i class="fa fa-search"></i></a>
    
    <div id="font-settings-wrapper" class="dropdown pull-left">
        <a href="#" class="btn toggle-dropdown" aria-label="&#x5B57;&#x578B;&#x8A2D;&#x5B9A;"><i class="fa fa-font"></i>
        </a>
        <div class="dropdown-menu font-settings">
    <div class="dropdown-caret">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>

    <div class="buttons">
        <button type="button" id="reduce-font-size" class="button size-2">A</button>
        <button type="button" id="enlarge-font-size" class="button size-2">A</button>
    </div>

    <div class="buttons font-family-list">
        <button type="button" data-font="0" class="button">&#x896F;&#x7DDA;&#x9AD4;</button>
        <button type="button" data-font="1" class="button">&#x7121;&#x896F;&#x7DDA;&#x9AD4;</button>
    </div>

    <div class="buttons color-theme-list">
        <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">&#x767D;&#x8272;</button>
        <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">&#x68D5;&#x8910;&#x8272;</button>
        <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">&#x591C;&#x9593;</button>
    </div>
</div>

    </div>

    <!-- Actions Right -->
    
    <div class="dropdown pull-right">
        <a href="#" class="btn toggle-dropdown" aria-label="&#x5206;&#x4EAB;"><i class="fa fa-share-alt"></i>
        </a>
        <div class="dropdown-menu font-settings dropdown-left">
            <div class="dropdown-caret">
                <span class="caret-outer"></span>
                <span class="caret-inner"></span>
            </div>
            <div class="buttons">
                <button type="button" data-sharing="twitter" class="button">
                    &#x5206;&#x4EAB;&#x5230; Twitter
                </button>
                <button type="button" data-sharing="google-plus" class="button">
                    &#x5206;&#x4EAB;&#x5230; Google
                </button>
                <button type="button" data-sharing="facebook" class="button">
                    &#x5206;&#x4EAB;&#x5230; Facebook
                </button>
                <button type="button" data-sharing="weibo" class="button">
                    &#x5206;&#x4EAB;&#x5230; Weibo
                </button>
                <button type="button" data-sharing="instapaper" class="button">
                    &#x5206;&#x4EAB;&#x5230; Instapaper
                </button>
            </div>
        </div>
    </div>
    

    
    <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a>
    
    
    


    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="index.html">ECMAScript 6&#x5165;&#x95E8;</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="ecmascript-6%E7%AE%80%E4%BB%8B">ECMAScript 6&#x7B80;&#x4ECB;</h1>
<p>ECMAScript 6&#xFF08;&#x4EE5;&#x4E0B;&#x7B80;&#x79F0;ES6&#xFF09;&#x662F;JavaScript&#x8BED;&#x8A00;&#x7684;&#x4E0B;&#x4E00;&#x4EE3;&#x6807;&#x51C6;&#xFF0C;&#x6B63;&#x5904;&#x5728;&#x5FEB;&#x901F;&#x5F00;&#x53D1;&#x4E4B;&#x4E2D;&#xFF0C;&#x5927;&#x90E8;&#x5206;&#x5DF2;&#x7ECF;&#x5B8C;&#x6210;&#x4E86;&#xFF0C;&#x9884;&#x8BA1;&#x5C06;&#x5728;2015&#x5E74;6&#x6708;&#x6B63;&#x5F0F;&#x53D1;&#x5E03;&#x3002;Mozilla&#x516C;&#x53F8;&#x5C06;&#x5728;&#x8FD9;&#x4E2A;&#x6807;&#x51C6;&#x7684;&#x57FA;&#x7840;&#x4E0A;&#xFF0C;&#x63A8;&#x51FA;JavaScript 2.0&#x3002;</p>
<p>ES6&#x7684;&#x76EE;&#x6807;&#xFF0C;&#x662F;&#x4F7F;&#x5F97;JavaScript&#x8BED;&#x8A00;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x7F16;&#x5199;&#x5927;&#x578B;&#x7684;&#x590D;&#x6742;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#xFF0C;&#x6210;&#x4E3A;&#x4F01;&#x4E1A;&#x7EA7;&#x5F00;&#x53D1;&#x8BED;&#x8A00;&#x3002;</p>
<h2 id="ecmascript%E5%92%8Cjavascript%E7%9A%84%E5%85%B3%E7%B3%BB">ECMAScript&#x548C;JavaScript&#x7684;&#x5173;&#x7CFB;</h2>
<p>ECMAScript&#x662F;JavaScript&#x8BED;&#x8A00;&#x7684;&#x56FD;&#x9645;&#x6807;&#x51C6;&#xFF0C;JavaScript&#x662F;ECMAScript&#x7684;&#x5B9E;&#x73B0;&#x3002;</p>
<p>1996&#x5E74;11&#x6708;&#xFF0C;JavaScript&#x7684;&#x521B;&#x9020;&#x8005;Netscape&#x516C;&#x53F8;&#xFF0C;&#x51B3;&#x5B9A;&#x5C06;JavaScript&#x63D0;&#x4EA4;&#x7ED9;&#x56FD;&#x9645;&#x6807;&#x51C6;&#x5316;&#x7EC4;&#x7EC7;ECMA&#xFF0C;&#x5E0C;&#x671B;&#x8FD9;&#x79CD;&#x8BED;&#x8A00;&#x80FD;&#x591F;&#x6210;&#x4E3A;&#x56FD;&#x9645;&#x6807;&#x51C6;&#x3002;&#x6B21;&#x5E74;&#xFF0C;ECMA&#x53D1;&#x5E03;262&#x53F7;&#x6807;&#x51C6;&#x6587;&#x4EF6;&#xFF08;ECMA-262&#xFF09;&#x7684;&#x7B2C;&#x4E00;&#x7248;&#xFF0C;&#x89C4;&#x5B9A;&#x4E86;&#x6D4F;&#x89C8;&#x5668;&#x811A;&#x672C;&#x8BED;&#x8A00;&#x7684;&#x6807;&#x51C6;&#xFF0C;&#x5E76;&#x5C06;&#x8FD9;&#x79CD;&#x8BED;&#x8A00;&#x79F0;&#x4E3A;ECMAScript&#x3002;&#x8FD9;&#x4E2A;&#x7248;&#x672C;&#x5C31;&#x662F;ECMAScript 1.0&#x7248;&#x3002;</p>
<p>&#x4E4B;&#x6240;&#x4EE5;&#x4E0D;&#x53EB;JavaScript&#xFF0C;&#x6709;&#x4E24;&#x4E2A;&#x539F;&#x56E0;&#x3002;&#x4E00;&#x662F;&#x5546;&#x6807;&#xFF0C;Java&#x662F;Sun&#x516C;&#x53F8;&#x7684;&#x5546;&#x6807;&#xFF0C;&#x6839;&#x636E;&#x6388;&#x6743;&#x534F;&#x8BAE;&#xFF0C;&#x53EA;&#x6709;Netscape&#x516C;&#x53F8;&#x53EF;&#x4EE5;&#x5408;&#x6CD5;&#x5730;&#x4F7F;&#x7528;JavaScript&#x8FD9;&#x4E2A;&#x540D;&#x5B57;&#xFF0C;&#x4E14;JavaScript&#x672C;&#x8EAB;&#x4E5F;&#x5DF2;&#x7ECF;&#x88AB;Netscape&#x516C;&#x53F8;&#x6CE8;&#x518C;&#x4E3A;&#x5546;&#x6807;&#x3002;&#x4E8C;&#x662F;&#x60F3;&#x4F53;&#x73B0;&#x8FD9;&#x95E8;&#x8BED;&#x8A00;&#x7684;&#x5236;&#x5B9A;&#x8005;&#x662F;ECMA&#xFF0C;&#x4E0D;&#x662F;Netscape&#xFF0C;&#x8FD9;&#x6837;&#x6709;&#x5229;&#x4E8E;&#x4FDD;&#x8BC1;&#x8FD9;&#x95E8;&#x8BED;&#x8A00;&#x7684;&#x5F00;&#x653E;&#x6027;&#x548C;&#x4E2D;&#x7ACB;&#x6027;&#x3002;&#x56E0;&#x6B64;&#xFF0C;ECMAScript&#x548C;JavaScript&#x7684;&#x5173;&#x7CFB;&#x662F;&#xFF0C;&#x524D;&#x8005;&#x662F;&#x540E;&#x8005;&#x7684;&#x89C4;&#x683C;&#xFF0C;&#x540E;&#x8005;&#x662F;&#x524D;&#x8005;&#x7684;&#x4E00;&#x79CD;&#x5B9E;&#x73B0;&#x3002;&#x5728;&#x65E5;&#x5E38;&#x573A;&#x5408;&#xFF0C;&#x8FD9;&#x4E24;&#x4E2A;&#x8BCD;&#x662F;&#x53EF;&#x4EE5;&#x4E92;&#x6362;&#x7684;&#x3002;</p>
<h2 id="ecmascript%E7%9A%84%E5%8E%86%E5%8F%B2">ECMAScript&#x7684;&#x5386;&#x53F2;</h2>
<p>1998&#x5E74;6&#x6708;&#xFF0C;ECMAScript 2.0&#x7248;&#x53D1;&#x5E03;&#x3002;</p>
<p>1999&#x5E74;12&#x6708;&#xFF0C;ECMAScript 3.0&#x7248;&#x53D1;&#x5E03;&#xFF0C;&#x6210;&#x4E3A;JavaScript&#x7684;&#x901A;&#x884C;&#x6807;&#x51C6;&#xFF0C;&#x5F97;&#x5230;&#x4E86;&#x5E7F;&#x6CDB;&#x652F;&#x6301;&#x3002;</p>
<p>2007&#x5E74;10&#x6708;&#xFF0C;ECMAScript 4.0&#x7248;&#x8349;&#x6848;&#x53D1;&#x5E03;&#xFF0C;&#x5BF9;3.0&#x7248;&#x505A;&#x4E86;&#x5927;&#x5E45;&#x5347;&#x7EA7;&#xFF0C;&#x9884;&#x8BA1;&#x6B21;&#x5E74;8&#x6708;&#x53D1;&#x5E03;&#x6B63;&#x5F0F;&#x7248;&#x672C;&#x3002;&#x8349;&#x6848;&#x53D1;&#x5E03;&#x540E;&#xFF0C;&#x7531;&#x4E8E;4.0&#x7248;&#x7684;&#x76EE;&#x6807;&#x8FC7;&#x4E8E;&#x6FC0;&#x8FDB;&#xFF0C;&#x5404;&#x65B9;&#x5BF9;&#x4E8E;&#x662F;&#x5426;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x6807;&#x51C6;&#xFF0C;&#x53D1;&#x751F;&#x4E86;&#x4E25;&#x91CD;&#x5206;&#x6B67;&#x3002;&#x4EE5;Yahoo&#x3001;Microsoft&#x3001;Google&#x4E3A;&#x9996;&#x7684;&#x5927;&#x516C;&#x53F8;&#xFF0C;&#x53CD;&#x5BF9;JavaScript&#x7684;&#x5927;&#x5E45;&#x5347;&#x7EA7;&#xFF0C;&#x4E3B;&#x5F20;&#x5C0F;&#x5E45;&#x6539;&#x52A8;&#xFF1B;&#x4EE5;JavaScript&#x521B;&#x9020;&#x8005;Brendan Eich&#x4E3A;&#x9996;&#x7684;Mozilla&#x516C;&#x53F8;&#xFF0C;&#x5219;&#x575A;&#x6301;&#x5F53;&#x524D;&#x7684;&#x8349;&#x6848;&#x3002;</p>
<p>2008&#x5E74;7&#x6708;&#xFF0C;&#x7531;&#x4E8E;&#x5BF9;&#x4E8E;&#x4E0B;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#x5E94;&#x8BE5;&#x5305;&#x62EC;&#x54EA;&#x4E9B;&#x529F;&#x80FD;&#xFF0C;&#x5404;&#x65B9;&#x5206;&#x6B67;&#x592A;&#x5927;&#xFF0C;&#x4E89;&#x8BBA;&#x8FC7;&#x4E8E;&#x6FC0;&#x8FDB;&#xFF0C;ECMA&#x5F00;&#x4F1A;&#x51B3;&#x5B9A;&#xFF0C;&#x4E2D;&#x6B62;ECMAScript 4.0&#x7684;&#x5F00;&#x53D1;&#xFF0C;&#x5C06;&#x5176;&#x4E2D;&#x6D89;&#x53CA;&#x73B0;&#x6709;&#x529F;&#x80FD;&#x6539;&#x5584;&#x7684;&#x4E00;&#x5C0F;&#x90E8;&#x5206;&#xFF0C;&#x53D1;&#x5E03;&#x4E3A;ECMAScript 3.1&#xFF0C;&#x800C;&#x5C06;&#x5176;&#x4ED6;&#x6FC0;&#x8FDB;&#x7684;&#x8BBE;&#x60F3;&#x6269;&#x5927;&#x8303;&#x56F4;&#xFF0C;&#x653E;&#x5165;&#x4EE5;&#x540E;&#x7684;&#x7248;&#x672C;&#xFF0C;&#x7531;&#x4E8E;&#x4F1A;&#x8BAE;&#x7684;&#x6C14;&#x6C1B;&#xFF0C;&#x8BE5;&#x7248;&#x672C;&#x7684;&#x9879;&#x76EE;&#x4EE3;&#x53F7;&#x8D77;&#x540D;&#x4E3A;Harmony&#xFF08;&#x548C;&#x8C10;&#xFF09;&#x3002;&#x4F1A;&#x540E;&#x4E0D;&#x4E45;&#xFF0C;ECMAScript 3.1&#x5C31;&#x6539;&#x540D;&#x4E3A;ECMAScript 5&#x3002;</p>
<p>2009&#x5E74;12&#x6708;&#xFF0C;ECMAScript 5.0&#x7248;&#x6B63;&#x5F0F;&#x53D1;&#x5E03;&#x3002;Harmony&#x9879;&#x76EE;&#x5219;&#x4E00;&#x5206;&#x4E3A;&#x4E8C;&#xFF0C;&#x4E00;&#x4E9B;&#x8F83;&#x4E3A;&#x53EF;&#x884C;&#x7684;&#x8BBE;&#x60F3;&#x5B9A;&#x540D;&#x4E3A;JavaScript.next&#x7EE7;&#x7EED;&#x5F00;&#x53D1;&#xFF0C;&#x540E;&#x6765;&#x6F14;&#x53D8;&#x6210;ECMAScript 6&#xFF1B;&#x4E00;&#x4E9B;&#x4E0D;&#x662F;&#x5F88;&#x6210;&#x719F;&#x7684;&#x8BBE;&#x60F3;&#xFF0C;&#x5219;&#x88AB;&#x89C6;&#x4E3A;JavaScript.next.next&#xFF0C;&#x5728;&#x66F4;&#x8FDC;&#x7684;&#x5C06;&#x6765;&#x518D;&#x8003;&#x8651;&#x63A8;&#x51FA;&#x3002;</p>
<p>2011&#x5E74;6&#x6708;&#xFF0C;ECMAscript 5.1&#x7248;&#x53D1;&#x5E03;&#xFF0C;&#x5E76;&#x4E14;&#x6210;&#x4E3A;ISO&#x56FD;&#x9645;&#x6807;&#x51C6;&#xFF08;ISO/IEC 16262:2011&#xFF09;&#x3002;</p>
<p>2013&#x5E74;3&#x6708;&#xFF0C;ECMAScript 6&#x8349;&#x6848;&#x51BB;&#x7ED3;&#xFF0C;&#x4E0D;&#x518D;&#x6DFB;&#x52A0;&#x65B0;&#x529F;&#x80FD;&#x3002;&#x65B0;&#x7684;&#x529F;&#x80FD;&#x8BBE;&#x60F3;&#x5C06;&#x88AB;&#x653E;&#x5230;ECMAScript 7&#x3002;</p>
<p>2013&#x5E74;12&#x6708;&#xFF0C;ECMAScript 6&#x8349;&#x6848;&#x53D1;&#x5E03;&#x3002;&#x7136;&#x540E;&#x662F;12&#x4E2A;&#x6708;&#x7684;&#x8BA8;&#x8BBA;&#x671F;&#xFF0C;&#x542C;&#x53D6;&#x5404;&#x65B9;&#x53CD;&#x9988;&#x3002;</p>
<p>2015&#x5E74;6&#x6708;&#xFF0C;ECMAScript 6&#x9884;&#x8BA1;&#x5C06;&#x53D1;&#x5E03;&#x6B63;&#x5F0F;&#x7248;&#x672C;&#x3002;</p>
<p>ECMA&#x7684;&#x7B2C;39&#x53F7;&#x6280;&#x672F;&#x4E13;&#x5BB6;&#x59D4;&#x5458;&#x4F1A;&#xFF08;Technical Committee 39&#xFF0C;&#x7B80;&#x79F0;TC39&#xFF09;&#x8D1F;&#x8D23;&#x5236;&#x8BA2;ECMAScript&#x6807;&#x51C6;&#xFF0C;&#x6210;&#x5458;&#x5305;&#x62EC;Microsoft&#x3001;Mozilla&#x3001;Google&#x7B49;&#x5927;&#x516C;&#x53F8;&#x3002;TC39&#x7684;&#x603B;&#x4F53;&#x8003;&#x8651;&#x662F;&#xFF0C;ES5&#x4E0E;ES3&#x57FA;&#x672C;&#x4FDD;&#x6301;&#x517C;&#x5BB9;&#xFF0C;&#x8F83;&#x5927;&#x7684;&#x8BED;&#x6CD5;&#x4FEE;&#x6B63;&#x548C;&#x65B0;&#x529F;&#x80FD;&#x52A0;&#x5165;&#xFF0C;&#x5C06;&#x7531;JavaScript.next&#x5B8C;&#x6210;&#x3002;&#x5F53;&#x524D;&#xFF0C;JavaScript.next&#x6307;&#x7684;&#x662F;ES6&#xFF0C;&#x5F53;&#x7B2C;&#x516D;&#x7248;&#x53D1;&#x5E03;&#x4EE5;&#x540E;&#xFF0C;&#x5C06;&#x6307;ES7&#x3002;TC39&#x8BA4;&#x4E3A;&#xFF0C;ES5&#x4F1A;&#x5728;2013&#x5E74;&#x7684;&#x5E74;&#x4E2D;&#x6210;&#x4E3A;JavaScript&#x5F00;&#x53D1;&#x7684;&#x4E3B;&#x6D41;&#x6807;&#x51C6;&#xFF0C;&#x5E76;&#x5728;&#x4ECA;&#x540E;&#x4E94;&#x5E74;&#x4E2D;&#x4E00;&#x76F4;&#x4FDD;&#x6301;&#x8FD9;&#x4E2A;&#x4F4D;&#x7F6E;&#x3002;</p>
<h2 id="%E9%83%A8%E7%BD%B2%E8%BF%9B%E5%BA%A6">&#x90E8;&#x7F72;&#x8FDB;&#x5EA6;</h2>
<p>&#x7531;&#x4E8E;ES6&#x8FD8;&#x6CA1;&#x6709;&#x5B9A;&#x6848;&#xFF0C;&#x6709;&#x4E9B;&#x8BED;&#x6CD5;&#x89C4;&#x5219;&#x8FD8;&#x4F1A;&#x53D8;&#x52A8;&#xFF0C;&#x76EE;&#x524D;&#x652F;&#x6301;ES6&#x7684;&#x8F6F;&#x4EF6;&#x548C;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x8FD8;&#x4E0D;&#x591A;&#x3002;&#x5404;&#x5927;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x6700;&#x65B0;&#x7248;&#x672C;&#xFF0C;&#x5BF9;ES6&#x7684;&#x652F;&#x6301;&#x53EF;&#x4EE5;&#x67E5;&#x770B;<a href="javascript:;" target="_blank">kangax.github.io/es5-compat-table/es6/</a>&#x3002;</p>
<p>Google&#x516C;&#x53F8;&#x7684;V8&#x5F15;&#x64CE;&#x5DF2;&#x7ECF;&#x90E8;&#x7F72;&#x4E86;ES6&#x7684;&#x90E8;&#x5206;&#x7279;&#x6027;&#x3002;&#x4F7F;&#x7528;Node.js 0.11&#x7248;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4F53;&#x9A8C;&#x8FD9;&#x4E9B;&#x7279;&#x6027;&#x3002;</p>
<p>Node.js&#x7684;0.11&#x7248;&#x8FD8;&#x4E0D;&#x662F;&#x7A33;&#x5B9A;&#x7248;&#x672C;&#xFF0C;&#x8981;&#x4F7F;&#x7528;&#x7248;&#x672C;&#x7BA1;&#x7406;&#x5DE5;&#x5177;<a href="javascript:;" target="_blank">nvm</a>&#x5207;&#x6362;&#x3002;&#x4E0B;&#x8F7D;nvm&#x4EE5;&#x540E;&#xFF0C;&#x8FDB;&#x5165;&#x9879;&#x76EE;&#x76EE;&#x5F55;&#xFF0C;&#x8FD0;&#x884C;&#x4E0B;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x3002;</p>
<pre><code class="lang-bash">
$ <span class="hljs-built_in">source</span> nvm.sh
$ nvm use <span class="hljs-number">0.11</span>
$ node --harmony
</code></pre>
<p>&#x542F;&#x52A8;&#x547D;&#x4EE4;&#x4E2D;&#x7684;<code>--harmony</code>&#x9009;&#x9879;&#x53EF;&#x4EE5;&#x6253;&#x5F00;&#x6240;&#x6709;&#x5DF2;&#x7ECF;&#x90E8;&#x7F72;&#x7684;ES6&#x529F;&#x80FD;&#x3002;&#x4F7F;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x547D;&#x4EE4;&#xFF0C;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x6240;&#x6709;&#x4E0E;ES6&#x6709;&#x5173;&#x7684;&#x5355;&#x4E2A;&#x9009;&#x9879;&#x3002;</p>
<pre><code class="lang-bash">
$ node --v8-options | grep harmony

  --harmony_typeof
  --harmony_scoping
  --harmony_modules
  --harmony_symbols
  --harmony_proxies
  --harmony_collections
  --harmony_observation
  --harmony_generators
  --harmony_iteration
  --harmony_numeric_literals
  --harmony_strings
  --harmony_arrays
  --harmony_maths
  --harmony
</code></pre>
<h2 id="traceur%E7%BC%96%E8%AF%91%E5%99%A8">Traceur&#x7F16;&#x8BD1;&#x5668;</h2>
<p>Google&#x516C;&#x53F8;&#x7684;<a href="javascript:;" target="_blank">Traceur</a>&#x7F16;&#x8BD1;&#x5668;&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;ES6&#x4EE3;&#x7801;&#x7F16;&#x8BD1;&#x4E3A;ES5&#x4EE3;&#x7801;&#x3002;&#x8FD9;&#x610F;&#x5473;&#x7740;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x7528;ES6&#x7684;&#x65B9;&#x5F0F;&#x7F16;&#x5199;&#x7A0B;&#x5E8F;&#xFF0C;&#x53C8;&#x4E0D;&#x7528;&#x62C5;&#x5FC3;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x652F;&#x6301;&#x3002;</p>
<p>&#x5B83;&#x6709;&#x591A;&#x79CD;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x3002;</p>
<p><strong>&#xFF08;1&#xFF09;&#x76F4;&#x63A5;&#x63D2;&#x5165;&#x7F51;&#x9875;</strong></p>
<p>Traceur&#x5141;&#x8BB8;&#x5C06;ES6&#x4EE3;&#x7801;&#x76F4;&#x63A5;&#x63D2;&#x5165;&#x7F51;&#x9875;&#x3002;</p>
<p>&#x9996;&#x5148;&#xFF0C;&#x5FC5;&#x987B;&#x5728;&#x7F51;&#x9875;&#x5934;&#x90E8;&#x52A0;&#x8F7D;Traceur&#x5E93;&#x6587;&#x4EF6;&#x3002;</p>
<pre><code class="lang-javascript">
&lt;!-- &#x52A0;&#x8F7D;Traceur&#x7F16;&#x8BD1;&#x5668; --&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-title">script</span> <span class="hljs-attribute">src</span>=<span class="hljs-value">&quot;http://google.github.io/traceur-compiler/bin/traceur.js&quot;</span>
        <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text/javascript&quot;</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
<span class="hljs-comment">&lt;!-- &#x5C06;Traceur&#x7F16;&#x8BD1;&#x5668;&#x7528;&#x4E8E;&#x7F51;&#x9875; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">script</span> <span class="hljs-attribute">src</span>=<span class="hljs-value">&quot;http://google.github.io/traceur-compiler/src/bootstrap.js&quot;</span>
        <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text/javascript&quot;</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
<span class="hljs-comment">&lt;!-- &#x6253;&#x5F00;&#x5B9E;&#x9A8C;&#x9009;&#x9879;&#xFF0C;&#x5426;&#x5219;&#x6709;&#x4E9B;&#x7279;&#x6027;&#x53EF;&#x80FD;&#x7F16;&#x8BD1;&#x4E0D;&#x6210;&#x529F; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">script</span>&gt;</span><span class="actionscript">
        traceur.options.experimental = <span class="hljs-literal">true</span>;
</span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
</span></code></pre>
<p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x628A;ES6&#x4EE3;&#x7801;&#x653E;&#x5165;&#x4E0A;&#x9762;&#x8FD9;&#x4E9B;&#x4EE3;&#x7801;&#x7684;&#x4E0B;&#x65B9;&#x3002;</p>
<pre><code class="lang-javascript">
&lt;script type=<span class="hljs-string">&quot;module&quot;</span>&gt;
    <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Calc</span> </span>{
        constructor(){
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Calc constructor&apos;</span>);
        }
        add(a, b){
            <span class="hljs-keyword">return</span> a + b;
        }
    }

    <span class="hljs-keyword">var</span> c = <span class="hljs-keyword">new</span> Calc();
    <span class="hljs-built_in">console</span>.log(c.add(<span class="hljs-number">4</span>,<span class="hljs-number">5</span>));
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
</span></code></pre>
<p>&#x6B63;&#x5E38;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4F1A;&#x5728;&#x63A7;&#x5236;&#x53F0;&#x6253;&#x5370;&#x51FA;9&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF0C;<code>script</code>&#x6807;&#x7B7E;&#x7684;<code>type</code>&#x5C5E;&#x6027;&#x7684;&#x503C;&#x662F;<code>module</code>&#xFF0C;&#x800C;&#x4E0D;&#x662F;<code>text/javascript</code>&#x3002;&#x8FD9;&#x662F;Traceur&#x7F16;&#x8BD1;&#x5668;&#x8BC6;&#x522B;ES6&#x4EE3;&#x7801;&#x7684;&#x6807;&#x8BC6;&#xFF0C;&#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x81EA;&#x52A8;&#x5C06;&#x6240;&#x6709;<code>type=module</code>&#x7684;&#x4EE3;&#x7801;&#x7F16;&#x8BD1;&#x4E3A;ES5&#xFF0C;&#x7136;&#x540E;&#x518D;&#x4EA4;&#x7ED9;&#x6D4F;&#x89C8;&#x5668;&#x6267;&#x884C;&#x3002;</p>
<p>&#x5982;&#x679C;ES6&#x4EE3;&#x7801;&#x662F;&#x4E00;&#x4E2A;&#x5916;&#x90E8;&#x6587;&#x4EF6;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;<code>script</code>&#x6807;&#x7B7E;&#x63D2;&#x5165;&#x7F51;&#x9875;&#x3002;</p>
<pre><code class="lang-javascript">
&lt;script type=<span class="hljs-string">&quot;module&quot;</span> src=<span class="hljs-string">&quot;calc.js&quot;</span> &gt;
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
</span></code></pre>
<p><strong>&#xFF08;2&#xFF09;&#x5728;&#x7EBF;&#x8F6C;&#x6362;</strong></p>
<p>Traceur&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;<a href="javascript:;" target="_blank">&#x5728;&#x7EBF;&#x7F16;&#x8BD1;&#x5668;</a>&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x7EBF;&#x5C06;ES6&#x4EE3;&#x7801;&#x8F6C;&#x4E3A;ES5&#x4EE3;&#x7801;&#x3002;&#x8F6C;&#x6362;&#x540E;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F5C;&#x4E3A;ES5&#x4EE3;&#x7801;&#x63D2;&#x5165;&#x7F51;&#x9875;&#x8FD0;&#x884C;&#x3002;</p>
<p>&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x8F6C;&#x4E3A;ES5&#x4EE3;&#x7801;&#x8FD0;&#x884C;&#xFF0C;&#x5C31;&#x662F;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x6837;&#x5B50;&#x3002;</p>
<pre><code class="lang-javascript">
&lt;script src=<span class="hljs-string">&quot;http://google.github.io/traceur-compiler/bin/traceur.js&quot;</span>
        type=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">script</span> <span class="hljs-attribute">src</span>=<span class="hljs-value">&quot;http://google.github.io/traceur-compiler/src/bootstrap.js&quot;</span>
        <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text/javascript&quot;</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span> 
<span class="hljs-tag">&lt;<span class="hljs-title">script</span>&gt;</span><span class="actionscript">
        traceur.options.experimental = <span class="hljs-literal">true</span>;
</span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">script</span>&gt;</span><span class="javascript">
$traceurRuntime.ModuleStore.getAnonymousModule(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
<span class="hljs-pi">    &quot;use strict&quot;</span>;

    <span class="hljs-keyword">var</span> Calc = <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Calc</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Calc constructor&apos;</span>);
    };

    ($traceurRuntime.createClass)(Calc, {add: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">a, b</span>) </span>{
        <span class="hljs-keyword">return</span> a + b;
    }}, {});

    <span class="hljs-keyword">var</span> c = <span class="hljs-keyword">new</span> Calc();
    <span class="hljs-built_in">console</span>.log(c.add(<span class="hljs-number">4</span>, <span class="hljs-number">5</span>));
    <span class="hljs-keyword">return</span> {};
});
</span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
</span></code></pre>
<p><strong>&#xFF08;3&#xFF09;&#x547D;&#x4EE4;&#x884C;&#x8F6C;&#x6362;</strong></p>
<p>&#x4F5C;&#x4E3A;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#x4F7F;&#x7528;&#x65F6;&#xFF0C;Traceur&#x662F;&#x4E00;&#x4E2A;node.js&#x7684;&#x6A21;&#x5757;&#xFF0C;&#x9996;&#x5148;&#x9700;&#x8981;&#x7528;npm&#x5B89;&#x88C5;&#x3002;</p>
<pre><code class="lang-bash">
$ npm install -g traceur
</code></pre>
<p>&#x5B89;&#x88C5;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E0B;&#x4F7F;&#x7528;traceur&#x4E86;&#x3002;</p>
<p>traceur&#x76F4;&#x63A5;&#x8FD0;&#x884C;es6&#x811A;&#x672C;&#x6587;&#x4EF6;&#xFF0C;&#x4F1A;&#x5728;&#x6807;&#x51C6;&#x8F93;&#x51FA;&#x663E;&#x793A;&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#xFF0C;&#x4EE5;&#x524D;&#x9762;&#x7684;calc.js&#x4E3A;&#x4F8B;&#x3002;</p>
<pre><code class="lang-bash">
$ traceur calc.js
Calc constructor
<span class="hljs-number">9</span>
</code></pre>
<p>&#x5982;&#x679C;&#x8981;&#x5C06;ES6&#x811A;&#x672C;&#x8F6C;&#x4E3A;ES5&#x4FDD;&#x5B58;&#xFF0C;&#x8981;&#x91C7;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x5199;&#x6CD5;</p>
<pre><code class="lang-bash">
$ traceur --script calc.es6.js --out calc.es5.js
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x7684;<code>--script</code>&#x9009;&#x9879;&#x8868;&#x793A;&#x6307;&#x5B9A;&#x8F93;&#x5165;&#x6587;&#x4EF6;&#xFF0C;<code>--out</code>&#x9009;&#x9879;&#x8868;&#x793A;&#x6307;&#x5B9A;&#x8F93;&#x51FA;&#x6587;&#x4EF6;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x9632;&#x6B62;&#x6709;&#x4E9B;&#x7279;&#x6027;&#x7F16;&#x8BD1;&#x4E0D;&#x6210;&#x529F;&#xFF0C;&#x6700;&#x597D;&#x52A0;&#x4E0A;<code>--experimental</code>&#x9009;&#x9879;&#x3002;</p>
<pre><code class="lang-bash">
$ traceur --script calc.es6.js --out calc.es5.js --experimental
</code></pre>
<p>&#x547D;&#x4EE4;&#x884C;&#x4E0B;&#x8F6C;&#x6362;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x653E;&#x5230;&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x8FD0;&#x884C;&#x3002;</p>
<p><strong>&#xFF08;4&#xFF09;Node.js&#x73AF;&#x5883;&#x7684;&#x7528;&#x6CD5;</strong></p>
<p>Traceur&#x7684;Node.js&#x7528;&#x6CD5;&#x5982;&#x4E0B;&#xFF08;&#x5047;&#x5B9A;&#x5DF2;&#x5B89;&#x88C5;traceur&#x6A21;&#x5757;&#xFF09;&#x3002;</p>
<pre><code class="lang-javascript">
<span class="hljs-keyword">var</span> traceur = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;traceur&apos;</span>);
<span class="hljs-keyword">var</span> fs = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;fs&apos;</span>);

<span class="hljs-comment">// &#x5C06;ES6&#x811A;&#x672C;&#x8F6C;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-keyword">var</span> contents = fs.readFileSync(<span class="hljs-string">&apos;es6-file.js&apos;</span>).toString();

<span class="hljs-keyword">var</span> result = traceur.compile(contents, {
  filename: <span class="hljs-string">&apos;es6-file.js&apos;</span>,
  sourceMap: <span class="hljs-literal">true</span>,
  <span class="hljs-comment">// &#x5176;&#x4ED6;&#x8BBE;&#x7F6E;</span>
  modules: <span class="hljs-string">&apos;commonjs&apos;</span>
});

<span class="hljs-keyword">if</span> (result.error)
  <span class="hljs-keyword">throw</span> result.error;

<span class="hljs-comment">// result&#x5BF9;&#x8C61;&#x7684;js&#x5C5E;&#x6027;&#x5C31;&#x662F;&#x8F6C;&#x6362;&#x540E;&#x7684;ES5&#x4EE3;&#x7801;  </span>
fs.writeFileSync(<span class="hljs-string">&apos;out.js&apos;</span>, result.js);
<span class="hljs-comment">// sourceMap&#x5C5E;&#x6027;&#x5BF9;&#x5E94;map&#x6587;&#x4EF6;</span>
fs.writeFileSync(<span class="hljs-string">&apos;out.js.map&apos;</span>, result.sourceMap);
</code></pre>
<h2 id="ecmascript-7">ECMAScript 7</h2>
<p>2013&#x5E74;3&#x6708;&#xFF0C;ES6&#x7684;&#x8349;&#x6848;&#x5C01;&#x95ED;&#xFF0C;&#x4E0D;&#x518D;&#x63A5;&#x53D7;&#x65B0;&#x529F;&#x80FD;&#x4E86;&#x3002;&#x65B0;&#x7684;&#x529F;&#x80FD;&#x5C06;&#x88AB;&#x52A0;&#x5165;ES7&#x3002;</p>
<p>ES7&#x53EF;&#x80FD;&#x5305;&#x62EC;&#x7684;&#x529F;&#x80FD;&#x6709;&#xFF1A;</p>
<p>&#xFF08;1&#xFF09;<strong>Object.observe</strong>&#xFF1A;&#x7528;&#x6765;&#x76D1;&#x542C;&#x5BF9;&#x8C61;&#xFF08;&#x4EE5;&#x53CA;&#x6570;&#x7EC4;&#xFF09;&#x7684;&#x53D8;&#x5316;&#x3002;&#x4E00;&#x65E6;&#x76D1;&#x542C;&#x5BF9;&#x8C61;&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF0C;&#x5C31;&#x4F1A;&#x89E6;&#x53D1;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x3002;</p>
<p>&#xFF08;2&#xFF09;<strong>Multi-Threading</strong>&#xFF1A;&#x591A;&#x7EBF;&#x7A0B;&#x652F;&#x6301;&#x3002;&#x76EE;&#x524D;&#xFF0C;Intel&#x548C;Mozilla&#x6709;&#x4E00;&#x4E2A;&#x5171;&#x540C;&#x7684;&#x7814;&#x7A76;&#x9879;&#x76EE;RiverTrail&#xFF0C;&#x81F4;&#x529B;&#x4E8E;&#x8BA9;JavaScript&#x591A;&#x7EBF;&#x7A0B;&#x8FD0;&#x884C;&#x3002;&#x9884;&#x8BA1;&#x8FD9;&#x4E2A;&#x9879;&#x76EE;&#x7684;&#x7814;&#x7A76;&#x6210;&#x679C;&#x4F1A;&#x88AB;&#x7EB3;&#x5165;ECMAScript&#x6807;&#x51C6;&#x3002;</p>
<p>&#xFF08;3&#xFF09;<strong>Traits</strong>&#xFF1A;&#x5B83;&#x5C06;&#x662F;&#x201C;&#x7C7B;&#x201D;&#x529F;&#x80FD;&#xFF08;class&#xFF09;&#x7684;&#x4E00;&#x4E2A;&#x66FF;&#x4EE3;&#x3002;&#x901A;&#x8FC7;&#x5B83;&#xFF0C;&#x4E0D;&#x540C;&#x7684;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x5206;&#x4EAB;&#x540C;&#x6837;&#x7684;&#x7279;&#x6027;&#x3002;</p>
<p>&#x5176;&#x4ED6;&#x53EF;&#x80FD;&#x5305;&#x62EC;&#x7684;&#x529F;&#x80FD;&#x8FD8;&#x6709;&#xFF1A;&#x66F4;&#x7CBE;&#x786E;&#x7684;&#x6570;&#x503C;&#x8BA1;&#x7B97;&#x3001;&#x6539;&#x5584;&#x7684;&#x5185;&#x5B58;&#x56DE;&#x6536;&#x3001;&#x589E;&#x5F3A;&#x7684;&#x8DE8;&#x7AD9;&#x70B9;&#x5B89;&#x5168;&#x3001;&#x7C7B;&#x578B;&#x5316;&#x7684;&#x66F4;&#x8D34;&#x8FD1;&#x786C;&#x4EF6;&#x7684;&#x4F4E;&#x7EA7;&#x522B;&#x64CD;&#x4F5C;&#x3001;&#x56FD;&#x9645;&#x5316;&#x652F;&#x6301;&#xFF08;Internationalization Support&#xFF09;&#x3001;&#x66F4;&#x591A;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x7B49;&#x7B49;&#x3002;</p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="index.html" class="navigation navigation-prev " aria-label="Previous page: &#x524D;&#x8A00;"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="let.html" class="navigation navigation-next " aria-label="Next page: let&#x548C;const&#x547D;&#x4EE4;"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="static/js/app.js"></script>

    
    <script src="static/js/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontSettings":{"theme":null,"family":"sans","size":2},"disqus":{"shortName":"git-book"}};
    gitbook.start(config);
});
</script>

        
    
    

</body></html>